#+TITLE: Jitsi Guide
#+AUTHOR: Zelphir Kaltstahl
#+STARTUP: content indent align inlineimages hideblocks entitiesplain nologdone nologreschedule nologredeadline nologrefile
#+TODO: TODO INPROGRESS | DONE
#+DATE: <2020-12-16 Wed>
#+LANGUAGE: English
#+PRIORITIES: A E E
#+OPTIONS: ^:{} H:10 toc:2
#+OPTIONS: tags:nil
#+OPTIONS: tasks:nil
#+OPTIONS: toc:nil
#+OPTIONS: H:6
#+OPTIONS: p:nil
#+OPTIONS: pri:nil
#+OPTIONS: prop:nil
#+OPTIONS: todo:nil
#+OPTIONS: stat:nil
#+OPTIONS: |:t
#+OPTIONS: inline:nil

* Jitsi Meet Guide

** Steps in Debian Buster VM

- aptitude
- synaptic package manager
- vim
- nginx (was already installed)
- apt-file

- download and add gpg key

  #+begin_src shell
  wget --quiet --output-document 'jitsi-key.gpg.key' https://download.jitsi.org/jitsi-key.gpg.key | cat 'jitsi-key.gpg.key' | apt-key add -
  sh -c "echo 'deb https://download.jitsi.org stable/' > /etc/apt/sources.list.d/jitsi-stable.list"
  #+end_src

- update repositories

  #+begin_src shell
  apt-get update
  #+end_src

- Setup NGINX:

  #+begin_src shell
  apt install -y nginx
  systemctl start nginx.service
  systemctl enable nginx.service
  #+end_src

- install jitsi-meet

  #+begin_src shell
  apt-get install --yes jitsi-meet
  #+end_src

- enter hostname for "Jitsi Videobridge"
  - perhaps localhost.com will work

- decide for self-signed certificate or custom certificate
  - later can run:

    #+begin_src shell
    sh /usr/share/jitsi-meet/scripts/install-letsencrypt-cert.sh
    #+end_src

** docker

*** Install docker

- remove old versions

  #+begin_src shell
  apt-get remove docker docker-engine docker.io containerd runc
  #+end_src

- update repos

  #+begin_src shell
  apt-get update
  #+end_src

- install required system packages

  #+begin_src shell
  apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
  #+end_src

- add docker gpg key

  #+begin_src shell
  curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
  apt-key fingerprint 0EBFCD88  # 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
  #+end_src

- add docker repository

  #+begin_src shell
  add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   stable"
  #+end_src

- update repos

  #+begin_src shell
  apt-get update
  #+end_src

- install docker packages

  #+begin_src shell
  apt-get install docker-ce docker-ce-cli containerd.io
  #+end_src

- add user to docker user group

  #+begin_src shell
  usermod -aG docker ${USER}
  #+end_src

- run hello world test

  #+begin_src shell
  docker run hello-world
  #+end_src

*** Uninstall docker

#+begin_src shell
apt-get purge docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker
rm -rf /var/lib/containerd
#+end_src

** Old Jitsi Meet Guide

This repository contains instructions on how to setup Jitsi.

This is work in progress.

*** Preparations

**** System packages

Update package source and packages:

#+begin_src shell
apt-get update && sudo apt upgrade
#+end_src

This might be optional: Enable HTTPS for APT:

#+begin_src shell
apt-get install apt-transport-https
#+end_src

Install ~curl~ if it is not installed already:

#+begin_src shell
apt-get install curl
#+end_src

~curl~ will be used later to install a GPG key. An alternative could be using ~wget~.

Add universe package repository:

#+begin_src shell
apt-add-repository universe
#+end_src

**** System configuration constants

***** Limits

Change the following values in ~/etc/systemd/system.conf~:

#+begin_src text
DefaultLimitNOFILE=65000
DefaultLimitNPROC=65000
DefaultTasksMax=65000
#+end_src

Then restart the service:

#+begin_src shell
systemctl daemon-reload
#+end_src

****** Explanation

(TODO: Why is it necessary to change these values?)

- ~DefaultLimitNOFILE=65000~ sets the maximum number of open file handles to 65000.
- ~DefaultLimitNPROC=65000~ sets the maximum number of running processes to 65000.
- ~DefaultTasksMax=65000~ sets the maximum number of running tasks to 65000.

***** Hostname

Configure the host name of the system:

#+begin_src shell
hostnamectl set-hostname <full domain of this server>
#+end_src

Additionally set the host name in ~/etc/hosts~:

#+begin_src text
127.0.0.1 localhost <domain>
#+end_src

****** Explanation

(TODO: Why is it required to set the host name using ~hostnamectl~?)

Setting the host name redirection in ~/etc/hosts~ allows us to make use of the domain name in a local deployment, avoiding DNS resolution for the domain of this server.

*** Installation of Jitsi Meet

**** System packages

***** Get the Jitsi GPG key

#+begin_src shell
curl https://download.jitsi.org/jitsi-key.gpg.key | sudo sh -c 'gpg --dearmor > /usr/share/keyrings/jitsi-keyring.gpg'
echo 'deb [signed-by=/usr/share/keyrings/jitsi-keyring.gpg] https://download.jitsi.org stable/' | sudo tee /etc/apt/sources.list.d/jitsi-stable.list > /dev/null
#+end_src

****** Explanation

apt packages are signed using a GPG key. This key is not already on the system usually. The key is used to calculate the checksums of apt packages, to verify integrity of transmitted packages.

1. ~curl https://download.jitsi.org/jitsi-key.gpg.key~ downloads the key.
2. ~sudo sh -c 'gpg --dearmor > /usr/share/keyrings/jitsi-keyring.gpg'~ un-ascii-armors the input using ~gpg --dearmor~ and uses super user privileges to write the un-ascii-armored key to ~/usr/share/keyrings/~.
3. ~echo 'deb [signed-by=/usr/share/keyrings/jitsi-keyring.gpg] https://download.jitsi.org stable/~ outputs the string ~deb [signed-by=/usr/share/keyrings/jitsi-keyring.gpg] https://download.jitsi.org stable/~.
4. ~sudo tee /etc/apt/sources.list.d/jitsi-stable.list > /dev/null~ outputs the input string and also writes it to the file ~/etc/apt/sources.list.d/jitsi-stable.list~. However, any output of ~tee~ itself is redirected to ~/dev/null~, so that it is discarded.

The combination of ~echo~ without ~sudo~, the pipe, and ~tee~ with ~sudo~ is required, because redirections are processed before commands (see: [[https://www.gnu.org/software/bash/manual/html_node/Redirections.html]]). Only redirecting using ~echo~ with ~sudo~ would not work, because the redirection ~>>~ would be processed before ~echo~ with ~sudo~ and a permission error would occur. Using ~tee~ the target file is not redirected to, but is an argument instead.
It is also stated at [[https://askubuntu.com/a/103644]].

*** Acknowledgement

Sources are for information are:

- [[https://scheible.it/jitsi-meet-server-installation/]]
-
